import { MutationTree, ActionTree, GetterTree, StoreOptions } from 'vuex'
import { States } from './type';

const state: States = {
  common: {}
}

const getters: GetterTree<States, any> = {
  token: (state: States) => state.common.token
}

const mutations: MutationTree<States> = {
  initCommonStore(state: States, data: any) {
    state.common = data
  },
  setCommonStore(state: States, data: any) {
    state.common = {
      ...state.common,
      ...data
    }
  }
}

const actions: ActionTree<States, any> = {}

const initStoreOptions: StoreOptions<States> = {
  actions,
  getters,
  state,
  mutations,
  strict: false
}

export default initStoreOptions
